// ----------------------------------------------------------------------------
//Casa@130523b
//VLSI Test.Test Compression.
//Write by Zhang Liang.
//E-mail:Lag.Zhang@gmail.com 
// ----------------------------------------------------------------------------
#include"global.h"
#include"testset.h"
#include"function.h"
#include"FDR.h"
#include"EFDR.h"
#include"VIHC.h"
#include"EVIHC.h"
#include"V9C.h"
#include"everytest.h"
#include"Hadamard.h"
#include"testsetXor.h"
#include"LFSR.h"


void start(int argc,char **argv)
{
	//Get testset
	vector<testset> _testsets;
	/*if(argc==1)
	for(auto cir_name:gSetting.circutes)
		_testsets.push_back(testset(cir_name));
	else*/
	{
		for(int i=1;i<argc;++i)
		_testsets.push_back(testset(argv[i]));
		}

	//do something at beginning
	
	//do something for every testset(ts)
	double sum=0;
	//table _table;
	for(auto &ts:_testsets)
	{

		double _Ratio=_test(ts);		
		sum+=_Ratio;
		
		//cout<<"<"<<ts.name()<<">  \t"<<setprecision(4)<<_Ratio<<endl;
		//cout<<"<"<<ts.name()<<">  \t"<<setprecision(4)<<_Ratio<<endl;
		/*
		for(int order=6;order<=9;order++)
			for(int time=1;time<=4;time++)
			{
				int L=(1<<order)*time;
				int _L=FDR::code(*testsetXor_horizontal::compress(*ts.data_string(),order,L))->length();
				_L+=(int)ceil((double)ts.size()/L)*(order+1);
				double _Ratio=testset::ratio(ts.size(),_L);
				_table.add(make_tuple(ts.name(),order,time,_Ratio));
			}*/
	}
	//_table.save("hadamard_horizon_order_length.xml");
	if(sum>0)
	{
	//cout<<"\n---\nAverage: \t"<<sum/_testsets.size()<<endl;
	}

}

  
int main(int argc,char **argv)
{

	try{
		//output log file
		/*
		if(!logfile.is_open())
		{
			throw msg(gSetting.logFile+":cannot open file");
		}
		//cout.rdbuf(log.rdbuf());

		cout<<"-----------------------------------\n"\
			<<__DATE__<<"     "<<__TIME__\
			<<"\nCasa@130524a\nVLSI Test.Test Compression.\n"
			<<"Write by Zhang Liang.\nE-mail:Lag.Zhang@gmail.com\n"\
			<<"https://code.google.com/p/vlsi-test/"\
			<<"\n-----------------------------------"<<endl;*/
		
		//Goto start
		start(argc,argv);
		
		//cout<<"\ntime used:"<<clock()<<"\ndone."<<endl;
		//logfile.close();
	}
	catch(msg &e)
	{
		simpleio::error("Main:",e);
	}
	catch(exception &e)
	{
		cerr<<"Main:"<<e.what()<<endl;
	}
//	cin.get();
	return 0;
}
